package com.bdqn.zhao.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bdqn.zhao.pojo.IpBuilding;
import com.bdqn.zhao.pojo.IpRoom;
import com.bdqn.zhao.pojo.QtComplaint;
import com.bdqn.zhao.dao.QtComplaintMapper;
import com.bdqn.zhao.service.QtComplaintService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.query.MPJLambdaQueryWrapper;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import lombok.val;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 投诉管理表 服务实现类
 * </p>
 *
 * @author zhangsan
 * @since 2023-04-24
 */
@Service
public class QtComplaintServiceImpl extends ServiceImpl<QtComplaintMapper, QtComplaint> implements QtComplaintService {
    @Resource
    private QtComplaintMapper qtComplaintMapper;

    @Override
    public List<QtComplaint> selectJ(String page, String size, String comolaintId) {
        Integer page1 = Integer.valueOf(page);
        Integer size1 = Integer.valueOf(size);
        List<QtComplaint> qtslt;
        if (comolaintId!=null){
            MPJLambdaWrapper<QtComplaint> wrapper = new MPJLambdaWrapper<QtComplaint>()
                    .selectAll(QtComplaint.class)
                    .select("ip_park.park_name")
                    .leftJoin("ip_park on t.name=ip_park.park_id ")
                    .eq("t.id",comolaintId);
            IPage<QtComplaint> iPage = new Page<>(page1, size1);
            IPage<QtComplaint> iPage1 = qtComplaintMapper.selectPage(iPage, wrapper);
            qtslt= iPage1.getRecords();
        }else {
        MPJLambdaWrapper<QtComplaint> wrapper = new MPJLambdaWrapper<QtComplaint>()
                .selectAll(QtComplaint.class)
                .select("ip_park.park_name")
                .leftJoin("ip_park on t.name=ip_park.park_id ");
        IPage<QtComplaint> iPage = new Page<>(page1, size1);
        IPage<QtComplaint> iPage1 = qtComplaintMapper.selectPage(iPage, wrapper);
        qtslt = iPage1.getRecords();
        }
        return qtslt;
    }

    @Override
    public int delectQt(int id) {
        return qtComplaintMapper.deleteById(id);
    }

    @Override
    public QtComplaint selectbyid(int id) {
        return qtComplaintMapper.selectById(id);
    }
}
